<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								学生名称：<input type="text" name="stuName"/>
							</li>

							<li>
								显示顺序：<input type="text" name="orderNum"/>
							</li>

							<li>
								学生号：<input type="text" name="stuNum"/>
							</li>

							<li>
								班级号：<input type="text" name="classNo"/>
							</li>

							<li>
								性别：<input type="text" name="sex"/>
							</li>
							<li>
								性别：<select name="sex" th:with="type=${@dict.getType('sys_user_sex')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>
							<li>
								生日：<input type="text" name="birthday"/>
							</li>

							<li>
								状态：<select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>

							<li>
								是否在读：<select name="delFlag" th:with="type=${@dict.getType('sys_teacher_status')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:student:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:student:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:student:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:student:export">
						<i class="fa fa-download"></i> 导出
				 </a>
				<a class="btn btn-success" id="upload" shiro:hasPermission="system:student:importExcel">
					<i class="fa fa-upload"></i> 导入
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
	 <script th:src="@{/ajax/libs/ajaxfile/ajaxupload.js}"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:student:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:student:remove')}]];
        var prefix = ctx + "system/student";
        var classdatas = [[${@dict.getType('sys_class_types')}]];
        var datas = [[${@dict.getType('sys_normal_disable')}]];
		var sexFlag=[[${@dict.getType('sys_user_sex')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                importExcelUrl: prefix + "/importExcel",
                modalName: "学生",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'stuId', 
					title : '学生ID',
					visible: false
				},
				{
					field : 'stuName', 
					title : '学生名称',
					sortable: true
				},
				{
					field : 'orderNum', 
					title : '显示顺序',
					sortable: true
				},
				{
					field : 'stuNum', 
					title : '学生号',
					sortable: true
				},
				{
					field : 'classNo', 
					title : '班级号',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(classdatas, value);
                    }
				},
				{
					field : 'sex', 
					title : '性别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sexFlag, value);
                    }
				},
				{
					field : 'birthday', 
					title : '生日',
					sortable: true
				},
				{
					field : 'status', 
					title : '状态（0正常 1停用）',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.stuId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.stuId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.stuId + '\')"><i class="fa fa-edit"></i>查看成绩</a> ');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        new AjaxUpload('#upload', {
            action: prefix+"/importExcel",
            name: 'file',
            autoSubmit:true,
            responseType:"json",
            onSubmit:function(file, extension){
                if (!(extension && /^(jpg|xlsx|jpeg|png|gif)$/.test(extension.toLowerCase()))){
                    alert('只支持jpg、png、gif格式的图片！');
                    return false;
                }
            },
            onComplete : function(file, r){
                $.operate.ajaxSuccess(r);
            }
        });
    </script>
</body>
</html>